<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <ProFilter v-model="filter.id" />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" prop="begin_create_time">
          <el-date-picker
            v-model="filter.begin_create_time"
            placeholder="开始时间"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            size="small"
            clearable
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" prop="end_create_time">
          <el-date-picker
            v-model="filter.end_create_time"
            placeholder="结束时间"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            size="small"
            clearable
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
          <el-button type="primary" size="small" @click="handleOut">导 出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="EQ单号" width="190px">
        <template slot-scope="{row}">
          {{ 'EQ'+row.id }}
        </template>
      </el-table-column>
      <el-table-column label="客户名称" width="220px" prop="lc_name" />
      <el-table-column label="项目名称" width="220px" prop="name" />
      <el-table-column label="时间" align="center" width="90px" prop="visit_time" />
      <el-table-column label="地址" width="220px" prop="addr" />
      <el-table-column label="联系人" width="180px" prop="visit_name" />
      <el-table-column label="联系电话" align="center" width="140px" prop="phone" />
      <el-table-column label="参加人员" width="260px" prop="participants" />
      <el-table-column label="交流内容" width="260px" prop="content" />
      <el-table-column label="客户反馈" width="260px" prop="feedback" />
      <el-table-column label="项目进度" width="160px" prop="schedule" />
      <el-table-column label="记录人" width="180px" prop="note_taker_name" />
      <el-table-column label="备注" min-width="260px" prop="remark" />
      <el-table-column label="操作" align="center" width="90px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                @click.native="handleDialog({...{pro_id: row.id}, ...
                {dTitle: '拜访记录信息', dType: 'edit', dField: dField}})"
              >
                拜访记录
              </el-dropdown-item>
              <!-- <el-dropdown-item @click.native="outData(row)">导 出</el-dropdown-item> -->
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Visits ref="dialog" :get-data="getList" :info="dialog" />
    <Cos ref="cos" :info="dialog" />
  </div>
</template>

<script>
import { visits, outPros } from '@/api/project'
import Visits from './components/visits-dialog'
import ProFilter from '@/components/ProFilter'
import page from '@/utils/page'

export default {
  name: '',
  components: { ProFilter, Visits },
  extends: page,
  props: {
    reqList: {
      default: visits,
      type: Function
    }
  },
  data() {
    return {
      parameter: { state: 0 },
      dField: ['pro_id']
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleOut() {
      outPros({
        ...this.filter
      }).then(response => {
        this.out(response)
      }).catch(err => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>
